package lib.Com;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;

import lib.Base.Settings;
import lib.Base.Friend;
import lib.Common.Path;
import lib.XML.XMLParser;

public class Container extends Thread {
	/**
	 * Object to hold several data which is used by different communication objects.
	 */
	public static ConcurrentHashMap<String, KnownClient> knownClients = new ConcurrentHashMap<String, KnownClient>();
	public static Settings settings = new XMLParser()
			.ParseSettings(Path.XML_PATH_MAIN + "settings.xml"); // new
																	// Settings();
	public static ArrayList<Friend> friendList = new ArrayList<Friend>();

	public static String ID = "";

	public static int Port1 = 5005;

	public static String IPlocal = null;
	public static String IPpublic = null;

	private boolean running = true;

	public Container(String UserId) {
		super("Container");
		ID = UserId;
		try {
			IPlocal = InetAddress.getLocalHost().getHostAddress();
			IPpublic = PublicIPAddress.getPublicIPAddress();
		} catch (Exception e) {
		}
	}

	public void run() {
		while (running) {
			try {
				Thread.sleep(50);
			} catch (Exception e) {
			}
		}
	}

	public void Stop() {
		running = false;
	}

	public static void RefreshIP() {
		try {
			IPlocal = InetAddress.getLocalHost().getHostAddress();
			IPpublic = PublicIPAddress.getPublicIPAddress();
		} catch (Exception e) {
		}
	}
}